/* ***********************
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is oisterBake.js module.
 *
 * The Initial Developer of the Original Code is Rob Gerns.
 *
 * Portions created by the Initial Developer are Copyright (C) 2010
 * the Initial Developer. All Rights Reserved.
 *
 **************************/


/****************************************************
* Function Name(s): oisterBake
*
* Purpose:
* Use AJAX to grab the XML file, call the "createSkelton"
* function to set up a basic structure on the HTML page 
* before going on to do anything else.  Call the 
* handleResponse() function only after the XML file is completely
* received and the skeleton structure is ready.
*
*****************************************************/	

function oisterBake(oisterURI) {

 if(document.getElementById("container") != null && document.getElementById("container") !=undefined){
    
	//Just to avoid confusion, if a "container" node is left over from something, remove it
	clearContainer();
 }
	
 theoisterfile = document.getElementById(oisterURI).value;  //the URI of the Oister file that is to be read 
	
 if(theoisterfile.indexOf('http://')==-1){
	theoisterfile = "http://"+theoisterfile;
 }
	
 http.open("GET", theoisterfile, true); //start an AJAX GET request for the file
    
 //Call the createSkelton function to generate some 'div' layers that will be used to contain content later
 createSkeleton();  
	
 //When the XML data is ready (after the createSkeleton() function executes, start the handleResponse function to get everything going
 http.onreadystatechange = function(){
  if(http.readyState==4 && http.status==200){ 
    handleResponse();
  }
 }
 
 http.send(null);	
 return true;
 
}